#!/usr/bin/env python

"""Logging based on logging module"""

import sys
import logging
import logging.handlers


class CLI(object):
    pass
   

def log_messages():
    """Step through the different logging levels and raise an exeption"""

    log.debug("debug message (value=10)")
    log.info("info message (value=20)")
    log.warn("warn message (value=30)")
    log.error("error message (value=40)")
    log.critical("critical message (value=50)")

    # UNcomment this block to test Exception handling and logging
    # try:
        # raise Exception("ZOMG tacos.")
    # except:
        # log.exception("Just like error, but with a traceback.")
   

log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)

# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

# create formatter
# formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")

format = '[%(asctime)s] %(levelname)-8s %(message)s'
datefmt = '%d-%b-%Y %H:%M:%S'
formatter = logging.Formatter(format, datefmt)

# add formatter to ch
ch.setFormatter(formatter)

# add ch to logger
log.addHandler(ch)

log.info("--- Logger configured for %s." % __name__)



#    """Set up basic configuration, out to stderr with a reasonable default format, no %(name)s"""
#    #
#    logging.basicConfig(level=(getattr(log, args.log_level)),
#                        format='[%(asctime)s] %(levelname)-8s %(message)s',
#                        datefmt='%d-%b-%Y %H:%M:%S',
#                        stream=args.log_output )


    
